﻿using open_api_sdk_csharp.com.chinaums.open.api;
using open_api_sdk_csharp.com.chinaums.open.api.annotation;
using open_api_sdk_csharp.com.chinaums.open.api.internals.utils;
using open_api_sdk_csharp.response;
using System;
//token请求request
namespace open_api_sdk_csharp.request
{
    public class TokenRequest : OpenApiRequest<TokenResponse>
    {

        public TokenRequest(string appId, string appKey)
        {
            this.AppId = appId;
            this.appKey = appKey;
            this.Timestamp = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
            this.Nonce = Guid.NewGuid().ToString("D");
            this.Signature = TokenUtils.generateSignature(this.appId, this.timestamp, this.nonce, this.appKey);
            this.AppKey = null;
        }
        [ApiField("appId", true, "开放平台开发者id")]
        public string AppId;
        public string appId {
            set { AppId = value; } get { return AppId; }
        }

        private String appKey;
        [ApiField("appKey", true, "开放平台开发者key")]
        public string AppKey {
            set { appKey = value; } get { return appKey; }
        }

        private String Timestamp;
        [ApiField("时间戳", true)]
        public string timestamp {
            set { Timestamp = value; } get { return Timestamp; }
        }

        private String Nonce;
        [ApiField("随机数", true)]
        public string nonce {
            set { Nonce = value; } get { return Nonce; }
        }

        private String Signature;
        [ApiField("SHA1签名字符", true)]
        public string signature { set { Signature = value; } get { return Signature; } }
        public string apiMethodName()
        {
            return "获取开放平台token";
        }
        public string apiVersion()
        {
            return "v1";
        }
        public bool needToken()
        {
            return false;
        }
        public Type responseClass<T>() where T : OpenApiResponse
        {
            return typeof(TokenResponse);
        }
        public string serviceCode()
        {
            return "/token/access";
        }
    }
}
